#include <openssl/sha.h>
#include <iostream>
#include <string.h>
#include <string>
#include <stdio.h>
#include "myhash.h"
char buf[SHA224_DIGEST_LENGTH*2+1]={0};

void test_sha224(const char* str,int32_t length)
{
    SHA256_CTX ctx;
    uint8_t* shaBuf=(uint8_t*)malloc(SHA224_DIGEST_LENGTH);
    SHA224_Init(&ctx);
    SHA224_Update(&ctx,str,length);
    SHA224_Final(shaBuf,&ctx);
    //得到的是二进制数  使用16进制输出显示
    //每个byte对应两个16进制字符
    for(int i=0;i<SHA224_DIGEST_LENGTH;i++){
        sprintf(&buf[i*2],"%02x",shaBuf[i]);
    }
    free(shaBuf);
}

int main()
{
    daniel::MyHash::ptr sha512Hash(new daniel::MyHash(daniel::MyHash::SHA512));
    const char* str1="hello world1";
    // unsigned char* str2="hello world2";
    sha512Hash->init();
    sha512Hash->update((void*)str1,strlen(str1));
    sha512Hash->final();
    std::cout<<"hash 1:"<<sha512Hash->toHashString()<<std::endl;

}